﻿@using Nop.Services.Configuration;
@using Nop.Core.Infrastructure;
@using Nop.Core.Domain.Cms;
@using Nop.Core;
@{
    Layout = "~/Views/Shared/_Root.cshtml";
}
@{
    //current category ID
    int currentCategoryId = 0;
    if (Url.RequestContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.InvariantCultureIgnoreCase) &&
        Url.RequestContext.RouteData.Values["action"].ToString().Equals("category", StringComparison.InvariantCultureIgnoreCase))
    {
        currentCategoryId = Convert.ToInt32(Url.RequestContext.RouteData.Values["categoryId"].ToString());
    }


    //current manufacturer ID
    int currentManufacturerId = 0;
    if (Url.RequestContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.InvariantCultureIgnoreCase) &&
        Url.RequestContext.RouteData.Values["action"].ToString().Equals("manufacturer", StringComparison.InvariantCultureIgnoreCase))
    {
        currentManufacturerId = Convert.ToInt32(Url.RequestContext.RouteData.Values["manufacturerId"].ToString());
    }


    //current product ID
    int currentProductId = 0;
    if (Url.RequestContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.InvariantCultureIgnoreCase) &&
        Url.RequestContext.RouteData.Values["action"].ToString().Equals("product", StringComparison.InvariantCultureIgnoreCase))
    {
        currentProductId = Convert.ToInt32(Url.RequestContext.RouteData.Values["productId"].ToString());
    }
}
<div class="center-2">
    @Html.Widget("main_column_before")
    @RenderBody()
    @Html.Widget("main_column_after")
</div>
<div class="side-2">
    @if (IsSectionDefined("left"))
    {
        @RenderSection("left")
    }
    else
    {
        @Html.Widget("left_side_column_before")
        
        @Html.Action("CategoryNavigation", "Catalog", new { currentCategoryId = currentCategoryId, currentProductId = currentProductId })
        
	    @Html.Widget("left_side_column_after_category_navigation")
	
        ISettingService settingService = EngineContext.Current.Resolve<ISettingService>();
        IStoreContext storeContext = EngineContext.Current.Resolve<IStoreContext>();
        WidgetSettings widgetSettings = EngineContext.Current.Resolve<WidgetSettings>();

        bool ajaxFiltersWidgetEnabled = widgetSettings.ActiveWidgetSystemNames.Contains("SevenSpikes.Nop.AjaxFilters");
        bool ajaxFiltersEnabled = settingService.GetSettingByKey<bool>("nopajaxfilterssettings.enableajaxfilters", false, storeContext.CurrentStore.Id, true);
        bool manufacturersFilterEnabled = settingService.GetSettingByKey<bool>("nopajaxfilterssettings.enablemanufacturersfilter", false, storeContext.CurrentStore.Id, true);
        
        if (!ajaxFiltersWidgetEnabled || !ajaxFiltersEnabled || !manufacturersFilterEnabled)
        {
            @Html.Action("ManufacturerNavigation", "Catalog", new { currentManufacturerId = currentManufacturerId })             
        }
        
        @Html.Action("PopularProductTags", "Catalog")

        @Html.Action("PollBlock", "Poll", new { systemKeyword = "LeftColumnPoll" })

        @Html.Action("RecentlyViewedProductsBlock", "Catalog")
        
        @Html.Widget("left_side_column_after")
    }
</div>

